package com.miki.sirius.demo.logic.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;
import springfox.documentation.swagger.web.SwaggerResource;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Surging
 * @version 1.0
 * @ClassName MyApiResourceController
 * @date 2022/1/17 18:36
 * @desc
 */
@Controller
@ApiIgnore
@RequestMapping({"/swagger-resources2"})//原来的swagger-resources会被重新分配至这里
public class MyApiResourceController {


    @RequestMapping( method = {RequestMethod.GET})
    @ResponseBody
    ResponseEntity<List<SwaggerResource>> swaggerResources() {

        List<SwaggerResource> result=new ArrayList<>();
        SwaggerResource r1=new SwaggerResource();
        r1.setName("default");

        //重置url，返回我们自己写的swaggerApi列表接口 chuck：2020/05/14
        r1.setLocation("/swagger/v2/api-docs");//核心是这里，此次出现问题，是由于springmvc里注解出现异常，
        // 导致api路径出问题，最终导致刷不出api列表
        r1.setSwaggerVersion("2.0");
        result.add(r1);

        return new ResponseEntity(result, HttpStatus.OK);
    }
}

